package com.srwl.mytx.widget;

import android.content.Context;
import android.util.AttributeSet;
import android.util.Log;
import android.view.View;
import android.widget.LinearLayout;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.PagerSnapHelper;
import androidx.recyclerview.widget.RecyclerView;

import com.amap.api.services.core.PoiItem;
import com.google.android.material.bottomsheet.BottomSheetBehavior;
import com.srwl.mytx.R;
import com.srwl.mytx.adapter.AddressSearchResultAdapter;
import com.srwl.mytx.adapter.MapBottomTopicAdapter;
import com.srwl.mytx.domain.Topic;

import java.util.List;

public class AddressSearchResultView extends LinearLayout {
    private static final String TAG = "AddressSearchResultView";
    RecyclerView rv_dialogItems;
    private AddressSearchResultAdapter topicAdapter;
    private Context context;

    public AddressSearchResultView(@NonNull Context context) {
        super(context);
        this.context = context;
        init();
    }


    public AddressSearchResultView(Context context, AttributeSet attrs) {
        super(context, attrs);
        this.context = context;
        init();
    }

    public AddressSearchResultView(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
        this.context = context;
        init();
    }


    private void init() {
        inflate(context, R.layout.bottom_dialog, this);
        rv_dialogItems = findViewById(R.id.rv_dialog);

    }

    public void init(List<PoiItem> topicList) {
        topicAdapter = new AddressSearchResultAdapter(context, topicList);
        rv_dialogItems.setLayoutManager(new LinearLayoutManager(context));
        rv_dialogItems.setAdapter(topicAdapter);
    }

    public void init(int position) {
        rv_dialogItems.scrollToPosition(position);
    }

    public void setListener(AddressSearchResultAdapter.OnItemClickListener listener) {
        topicAdapter.setOnItemClickListener(listener);
    }

    public void notifyDataSetChange() {
        topicAdapter.notifyDataSetChanged();
    }


}
